package com.hmdp.config;

import com.hmdp.utils.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {
    /*
    配置拦截器 LoginInterceptor
     排除一些不需要拦截的路径
     这里配置了拦截器 LoginInterceptor，排除一些不需要拦截的路径，比如 /user/login、/user/code、/shop/**、shop-type/**、upload/**、blog/hot、/voucher/**
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //通过 exclude 排序一些拦截的内容
        registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns("/user/login", "/user/code",
                        "/shop/**", "/shop-type/**", "/upload/**", "/blog/hot", "/voucher/**","/hot/**","/list/**").order(1);
    }
}
